﻿using LPLS.Commons.DBModule;
using LPLS.Commons.Enums;
using LPLS.DBEntities;
using LPLS.DBEntities.OEEModule.OEEModels.TimeUtilizationModels;
using LPLS.DBInterface.OEEModule.OEEModels.TimeUtilizationModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LPLS.DBServices.OEEModule.OEEModels.TimeUtilizationModels
{
    public class TimeUtilizationRateConfigService : DBBaseService, ITimeUtilizationRateConfigService
    {
        public TimeUtilizationRateConfigService(DBContext dbContext) : base(dbContext)
        {




        }

     

        public int AddData(List<TimeUtilizationRateConfig> li, Guid deviceid,int type, DeviceComponentTypeEnum c)
        {
           this.Client.Deleteable<TimeUtilizationRateConfig>().Where(e=>e.DeviceID==deviceid&&e.Type==type&&e.CompentType==c).ExecuteCommand();

          return   this.Client.Insertable(li).ExecuteCommand();
        }

        public List<TimeUtilizationRateConfig> GetData(Guid deviceid, DeviceComponentTypeEnum compentType)
        {
           return this.Client.Queryable<TimeUtilizationRateConfig>().Where(e=>e.DeviceID==deviceid&&e.CompentType==compentType).ToList();
        }

        public override void InitDataBaseName()
        {
            DataBaseName = DatabaseEnum.CollectionDataResult.ToString();
        }

        public int UpdataData(List<TimeUtilizationRateConfig> li)
        {
           return this.Client.Updateable(li).ExecuteCommand();
        }
    }
}
